$(document).ready(function ()
{
    var parentId = getQueryString("parentId");
    var currentid = getQueryString("currentid");

    layui.use('upload', function ()
    {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        get_dictinoary_parentList("parent_id", form, parentId, currentid);
    });

    $("#btn_submit").on("click", function ()
    {
        add(parentId);
    });
});


function add(parentId)
{
    var params = param();
    $.ajax({
        cache: true,
        type: "POST",
        url: ctx+"/system/dictinoaryType/save",
        data: params,
        async: false,
        error: function (request)
        {
            parent.layer.alert("Connection error");
        },
        success: function (data)
        {
            if (data.code == 0)
            {
                parent.layer.msg("操作成功");
                parent.reload();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else
            {
                parent.layer.alert(data.msg)
            }

        }
    });

}



function param()
{
    return {
        "parentId": $("#parent_id").val(),
        "dictinoaryName": $("#dictinoary_name").val(),
        "dictinoaryValue": $("#dictinoary_value").val()
    };
}
